package edu.hawaii.duedates.wicket;

import org.apache.wicket.behavior.HeaderContributor;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;

/**
 * This is the base page that will hold the links, in tabs, to the alert and display page.
 * 
 * @author robin
 *
 */
public class BasePage extends DueDatesPage {

  /** Support serialization. */
  private static final long serialVersionUID = 1L;
  
  /**
   * Constructor for the Base Page.
   */
  public BasePage() {
    
    // Add CSS definitions for use in all pages
    add(HeaderContributor.forCss(edu.hawaii.duedates.wicket.BasePage.class, 
        "basepage.css", "screen"));
    
    add(new Label("title", "DueDates 2.0"));
    
    add(new Link("alertPageLink") {
      private static final long serialVersionUID = 1L;
      @Override
      public void onClick() {
        setResponsePage(new AlertPage());
      }
    });
    
    add(new Link("displayPageLink") {
      private static final long serialVersionUID = 1L;
      /**
       * Set the destination of the link to display page. 
       */
      @Override
      public void onClick() {
        setResponsePage(new DisplayPage());
      }
    });
    
    add(new Link("signOut") {
      
      private static final long serialVersionUID = 1L;
      /**
       * Log out of the session.
       */
      @Override
      public void onClick() {
        getSession().invalidate();
        getDueDates().getItemList().clear();
        getDueDates().setUser(null);
        getDueDates().setLibraryFilterNone();
        setResponsePage(Index.class);
      }
    });
  }
}
